from PySide2.QtWidgets import QMainWindow, QApplication, QComboBox, QStackedWidget, QVBoxLayout, QWidget
# 新增页面类导入
from .page1 import Page1
from .page2 import Page2
from .page3 import Page3
from .page4 import Page4

class MainWindow(QMainWindow):
    def __init__(self):
        super().__init__()
        self.setWindowTitle("角差计算和a点计算公式")
        self.setGeometry(100, 100, 400, 300)

        # 创建下拉菜单
        self.combo = QComboBox()
        self.combo.addItems(["夹角公式上倾井", "夹角公式下倾井", "预测垂深公式上倾井", "预测垂深公式下倾井"])
        self.combo.currentIndexChanged.connect(self.on_combobox_changed)

        # 创建堆栈容器
        self.stacked_widget = QStackedWidget()

        # 修改页面创建方式
        self.pages = [
            Page1(),
            Page2(),
            Page3(),
            Page4()
        ]
        for page in self.pages:
            self.stacked_widget.addWidget(page)

        # 总布局
        layout = QVBoxLayout()
        layout.addWidget(self.combo)
        layout.addWidget(self.stacked_widget)

        container = QWidget()
        container.setLayout(layout)
        self.setCentralWidget(container)

    def on_combobox_changed(self, index):
        self.stacked_widget.setCurrentIndex(index)